* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  font: 14px menu;
  --bg: var(--fill-0);
  --fg: var(--fill-15);
  --fill-0: #fff;
  --fill-0-5: #f7f7f7;
  --fill-1: #eee; // step = 0x11
  --fill-2: #ddd;
  --fill-3: #ccc;
  --fill-4: #bbb;
  --fill-5: #aaa;
  --fill-6: #bbb;
  --fill-7: #888;
  --fill-8: #777;
  --fill-9: #666;
  --fill-10: #555;
  --fill-11: #444;
  --fill-12: #333;
  --fill-13: #222;
  --fill-14: #111;
  --fill-15: #000;
  --tooltip-color: white;
  --tooltip-bg: rgba(0,0,0,.8);
  --tooltip-border-color: transparent;
  @media (prefers-color-scheme: dark) {
    --fill-0: #222222;
    --fill-0-5: #272727;
    --fill-1: #2c2c2c; // step = 0x0A
    --fill-2: #363636;
    --fill-3: #404040;
    --fill-4: #4a4a4a;
    --fill-5: #545454;
    --fill-6: #5e5e5e;
    --fill-7: #686868;
    --fill-8: #727272;
    --fill-9: #7c7c7c;
    --fill-10: #868686;
    --fill-11: #909090;
    --fill-12: #9a9a9a;
    --fill-13: #a4a4a4;
    --fill-14: #aeaeae;
    --fill-15: #b8b8b8;
    --tooltip-border-color: #8888;
  }
}

body {
  overflow: hidden; // avoid flash of viewport caused by tooltip
  font-size: 1rem;
  background: var(--bg);
  color: var(--fg);
}

// Form elements will not inherit
body,
button,
select,
input,
textarea {
  font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 1rem;
}

h1 {
  font-size: 1.5rem;
}
h1, h2 {
  margin-top: .5em;
  margin-bottom: .5em;
}
a {
  color: dodgerblue;
  @media (prefers-color-scheme: dark) {
    color: #7baaff;
  }
}
hr {
  margin: .5rem;
  border: none;
  border-top: 1px solid var(--fill-7);
}
input[disabled] ~ * {
  opacity: .5;
}
input[type=text],
input[type=search],
input[type=password] {
  line-height: 1.5rem;
  &[disabled] {
    background: var(--fill-1);
    cursor: not-allowed;
  }
}
textarea {
  display: block;
  width: 100%;
}
input[type=text],
input[type=search],
input[type=password],
textarea {
  padding: 0 .5rem;
  border: 1px solid var(--fill-3);
  &:focus {
    border-color: var(--fill-7);
  }
  &.has-error {
    // reminder: make sure all colors are readable in light/dark schemes
    border-color: #8008;
    background: #f002;
    &:focus {
      border-color: #f008;
    }
  }
}
code {
  padding: 0 .2em;
  background: hsla(50, 100%, 50%, .35);
  @media (prefers-color-scheme: dark) {
    background: hsla(40, 100%, 50%, .2);
  }
}

fieldset {
  display: inline-block;
  padding: .5rem;
  border: 1px solid var(--fill-3);
}

:focus {
  outline: none;
}

.icon {
  width: 1rem;
  height: 1rem;
}

// Firefox does not support `svg path` selector
svg {
  fill: currentColor;
}

button {
  border: 1px solid var(--fill-5);
  background: var(--fill-1);
  @media (prefers-color-scheme: dark) {
    background: var(--fill-2);
  }
  color: var(--fg);
  &:not([disabled]):hover {
    border-color: var(--fill-7);
  }
  &:active {
    background: var(--fill-5);
  }
  &:focus {
    border-color: var(--fg);
  }
  &[disabled] {
    opacity: .5;
  }
  &:not([disabled]) {
    cursor: pointer;
  }
}

button,
.btn-ghost,
.sep {
  display: inline-block;
  padding: 0 .5rem;
  font-size: 1rem;
  line-height: 1.5;
  vertical-align: bottom;
}
.btn-ghost {
  color: inherit;
  border: 1px solid transparent;
  cursor: pointer;
  &:hover {
    border-color: var(--fill-5);
    background: var(--bg);
  }
  > .icon {
    display: block;
    height: 2rem;
  }
  &.active {
    background: var(--fill-1);
    border-color: var(--fill-4);
  }
}

.sep {
  &::after {
    content: '';
    border-right: 1px solid var(--fill-4);
  }
}

ul,
ol {
  padding-left: 20px;
}
li {
  line-height: 1.4;
}

.inline-block {
  display: inline-block;
}
.flex {
  display: flex;
}
.flex-col {
  flex-direction: column;
}
.flex-wrap {
  flex-wrap: wrap;
}
.flex-auto {
  flex: auto;
  .flex-col > & {
    height: 0;
  }
  :not(.flex-col) > & {
    width: 0;
  }
}
.flex-1 {
  flex: 1;
}
.pos-rel {
  position: relative;
}
.ml-1 {
  margin-left: .5em;
}
.mr-1 {
  margin-right: .5em;
}
.ml-2 {
  margin-left: 1em;
}
.mr-2 {
  margin-right: 1em;
}
.mt-1 {
  margin-top: .5em;
}
.mb-1 {
  margin-bottom: .5em;
}
.mb-2 {
  margin-bottom: 1em;
}
.mx-1 {
  margin-left: .5em;
  margin-right: .5em;
}
.my-1 {
  margin-top: .5em;
  margin-bottom: .5em;
}
.h-100 {
  height: 100%;
}
.w-1 {
  width: 4em;
}
.fixed-full {
  position: fixed;
}
.abs-full {
  position: absolute;
}
.fixed-full,
.abs-full {
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}
.ellipsis {
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.text-center {
  text-align: center;
}
.text-right {
  text-align: right;
}
.scroll-y {
  overflow-y: auto;
}

.frame {
  background: var(--fill-1);
  &-block {
    padding: .5rem;
  }
}

.editor-code .CodeMirror {
  height: 100%;
}

.monospace-font,
.editor-code .CodeMirror {
  /* Use `Courier New` to ensure `&nbsp;` has the same width as an original space. */
  font-family: "Fira Code", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", Courier, monospace;
}

body .vl-tooltip {
  z-index: 10000;
  > i {
    color: var(--tooltip-bg);
    z-index: 1;
  }
  &-content {
    margin: -1px;
    border: 1px solid var(--tooltip-border-color);
    color: var(--tooltip-color);
    background: var(--tooltip-bg);
  }
}

.vl-dropdown-menu {
  padding: .5rem;
  border: 1px solid var(--fill-4);
  background: var(--bg);
}

.modal-content {
  margin: 0 auto;
  padding: 1rem;
  background: var(--bg);
  box-shadow: 0 0 40px #000;
}

@media (prefers-color-scheme: dark) {
  input[type="radio"],
  input[type="checkbox"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 1em;
    height: 1em;
    background: #111;
    position: relative;
    border: 1px solid #555;
    &:checked::after {
      content: "";
      background: var(--fg);
      border: 1px solid var(--bg);
      top: 2px;
      left: 2px;
      right: 2px;
      bottom: 2px;
      position: absolute;
    }
  }
  input[type="radio"],
  input[type="radio"]:checked::after {
    border-radius: 1em;
  }
  input[type="text"],
  input[type="search"],
  input[type="number"],
  input[type="password"],
  select,
  textarea {
    background: #111;
    color: var(--fg);
    border: 1px solid var(--fill-4);
  }
  ::-webkit-scrollbar {
    width: 14px;
    height: 14px;
    background: #1a1a1a;
    &-button:single-button {
      background: radial-gradient(circle at center, #333 40%, #1a1a1a 40%);
      &:hover {
        background: radial-gradient(circle at center, #444 40%, #1a1a1a 40%);
      }
      &:active {
        background: radial-gradient(circle at center, #555 40%, #1a1a1a 40%);
      }
    }
    &-track-piece {
      background: #333;
      border: 4px solid #1a1a1a;
      border-radius: 8px;
      &:hover {
        background: #444;
      }
      &:active {
        background: #555;
      }
    }
    &-thumb {
      border: 3px solid #1a1a1a;
      border-radius: 8px;
      background: #555;
      &:hover {
        background: #666;
      }
      &:active {
        background: #777;
      }
    }
  }
  :-webkit-autofill {
    box-shadow: 0 0 0 1000px #111 inset;
    -webkit-text-fill-color: #fff;
  }
}

@media (min-width: 768px) {
  .visible-sm {
    display: none;
  }
}

@media (max-width: 767px) {
  .hidden-sm {
    display: none !important;
  }
}

@media (max-width: 319px) {
  .hidden-xs {
    display: none !important;
  }
}
